/**
 * Filename: PinyinComparator.java
 * @author  Firefly
 * @contact postfirefly@163.com
 * @time    2016/3/9 1:18
 */
package com.github.postsanf.yinian.utils;

import com.github.postsanf.yinian.bean.YNContactUser;

import java.util.Comparator;

/**
 * 拼音汉字比对
 */
public class PinyinComparator implements Comparator<YNContactUser> {

    public int compare(YNContactUser o1, YNContactUser o2) {
        if (o1.getNameLetters().equals("@")
                || o2.getNameLetters().equals("#")) {
            return -1;
        } else if (o1.getNameLetters().equals("#")
                || o2.getNameLetters().equals("@")) {
            return 1;
        } else {
            return o1.getNameLetters().compareTo(o2.getNameLetters());
        }
    }
}
